#!/bin/sh

read -p "Enter version: " VERSION

RELEASE_DIR='00_releases'
APP_NAME='filerunner'
CFG_FILE="${APP_NAME}.cfg"
DST_DIR="${APP_NAME}_${VERSION}"
CONST_FILE='lib/myconst.py'

cd ../
rm -rf $DST_DIR
mkdir -p $RELEASE_DIR
mkdir $DST_DIR

cp -Lrf *.py $DST_DIR
cp -Lrf lib $DST_DIR
cp -Lrf $CFG_FILE $DST_DIR
cp -Lrf img $DST_DIR

sed s/VERSION/v$VERSION/g docs/README > $DST_DIR/README
sed -e "s/<DEVEL-VERSION>/$VERSION/g" -e "s/00_$CFG_FILE/$CFG_FILE/g" $CONST_FILE > $DST_DIR/$CONST_FILE

find $DST_DIR -iname '*.pyc' -exec rm {} \;

tar cfz ${DST_DIR}.tar.gz $DST_DIR
mv ${DST_DIR}.tar.gz $RELEASE_DIR
cp $DST_DIR/README $RELEASE_DIR
rm -rf $DST_DIR
